package com.exam.ch9;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class JEditorPane3 {
	
	public static void main(String[] args){
		
		JEditorPane editPane = null;
		try{
              URL address = new URL("http://www.baidu.com"); 
              editPane = new JEditorPane(address);
              editPane.setContentType("text/html");
        	}catch(MalformedURLException e){
        	  System.out.println("Malformed URL: " + e);
        	}catch(IOException e){
	    	  System.out.println("IOException: " + e);
		}
		editPane.setEditable(false);

		JFrame f = new JFrame("JEditorPane3");
		f.setContentPane(new JScrollPane(editPane));
		f.setSize(200,250);
    	f.setVisible(true);
    		f.addWindowListener(new WindowAdapter() {            
    		  public void windowClosing(WindowEvent e) {                    
    		 	  System.exit(0);            
    		  }        
    		});    
	}
	
}
